package com.ebuilder.actions;

import com.ebuilder.services.PersonManagementService;
import com.ebuilder.services.PersonManagementServiceImpl;
import com.opensymphony.xwork2.ActionSupport;



public class RegisterAction extends ActionSupport {

	private String userId;
	private String password;
	private String email;
	private String address;
	private int phone;
	
	public String execute() throws Exception {

		PersonManagementService ps = new PersonManagementServiceImpl();
		
		if(ps.register(getUserId(), getPassword(), getEmail(), getAddress(), getPhone())) {
			return SUCCESS;
		}
		
		return ERROR;
	}

	public void validate() {
		if(getUserId().length() == 0) {
			addFieldError("userId", "User Name Cannot be empty");
		}
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public int getPhone() {
		return phone;
	}

	public void setPhone(int phone) {
		this.phone = phone;
	}
}
